#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename:   05-vga-industrial.sh
# Version:    1.0
# Date:       2020/05/15
# Author:     Lz
# Email:      lz843723683@gmail.com
# History：     
#             Version 1.0, 2020/05/15
# Function:   自适应分辨率
# Out:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
VgaClean_FTGW_INDUSTRIAL(){
	return $TPASS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
VgaExit_FTGW_INDUSTRIAL(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 用户界面
#
VgaUSAGE_FTGW_INDUSTRIAL(){
	USAGE_FTLIB "金风工控版本 - 自适应分辨率"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
VgaInit_FTGW_INDUSTRIAL(){
        # 调用初始化函数
	Init_FTLIB "VgaClean_FTGW_INDUSTRIAL"
        # 调用用户界面函数
 	VgaUSAGE_FTGW_INDUSTRIAL
}


## TODO ：强制分辨率
#
VgaTest01_FTGW_INDUSTRIAL(){
	local flag="vga=0x317"
	local field="GRUB_CMDLINE_LINUX"
	local cfgfile="/etc/default/grub"

	# 判断是否存在cfgfile文件
	if [ ! -f "$cfgfile" ];then
		# 不存在配置文件
		false
        	RetParse_FTLIB "存在 ${cfgfile} 文件 " "False"

		return $TFAIL
	fi

        # 判断se配置文件
        echo 'cat' "${cfgfile}"
        cat ${cfgfile} | grep "^${field}"
        cat ${cfgfile} | grep "^${field}" | grep -v -i -q ${flag}
        RetParse_FTLIB "${cfgfile} 默认不包含配置 ${flag} " "False"
}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
VgaMain_FTGW_INDUSTRIAL(){
	VgaInit_FTGW_INDUSTRIAL

	VgaTest01_FTGW_INDUSTRIAL

	return ${TPASS}	
}

VgaMain_FTGW_INDUSTRIAL
VgaExit_FTGW_INDUSTRIAL $?
